package com.lanqiao.homework;

import java.util.Scanner;

public class StudentMaster {

	// 学生信息
	private Student[] arrStu;
	
	//show最终排名
	public void show() {
		init();
		sort();
		prf();
	}

	// 	初始化学生信息
	private void init() {

		Scanner sc = new Scanner(System.in);
		// 	输入学生人数
		System.out.println("请输入学生人数：");
		int count = sc.nextInt();
		// 	定义数组长度
		arrStu = new Student[count];
		for (int i = 0; i < count; i++) {
			System.out.println("请输入第"+(i+1)+"个学生姓名");
			String stuName = sc.next();
			System.out.println("请输入第"+(i+1)+"个学生学号");
			String stuNo = sc.next();
			System.out.println("请输入第"+(i+1)+"个学生成绩");
			double stuScore = sc.nextDouble();
			arrStu[i] = new Student(stuNo,stuName,stuScore);
		}
	}
	
	//排序(冒泡排序)
	public void sort() {
		for(int i = 0;i<arrStu.length;i++) {
			for(int j = 0;j <arrStu.length - 1 -i;j++) {
				if(arrStu[j].getStuScore() < arrStu[j+1].getStuScore()) {
				Student temp = arrStu[j];
				arrStu[j] = arrStu[j+1];
				arrStu[j+1] = temp;
				}
			}
		}
	}
	
	public void prf() {
		for (Student i : arrStu) {
			i.printMe();
		}
		System.out.println();
	}
}
